Analyze and Understand Other People’s Regular Expressions
Learn Regex By Example

When you need to edit a regular expression written by somebody else, or if you are just curious to understand or study a regex you encountered, copy and paste it into RegexBuddy. If the regex is used as part of an application’s source code, just copy the entire string or regex operator, and let RegexBuddy extract the regex from the string. When working with Java code, for example, copy the Java string containing the regex and select “Paste as Java string” in RegexBuddy. RegexBuddy then properly removes the quotes and escape characters.

As soon as you paste in the regex, RegexBuddy’s regex tree gives you a clear analysis of the regular expression. Click on the regular expression, or on the regex tree, to highlight corresponding parts. Collapse part of the tree to get a good overview of complex regular expressions. If you are new to regular expressions, this is an excellent way to learn by example.

RegexBuddy’s analysis is not some generic description of the regex syntax. It explains exactly how your chosen application interprets each part of the regular expression. In the screen shot, \d is explained as “Match a single character that is a digit (ASCII 0–9 only)” because that’s what Java does. If the application were changed to C#, this would change to “Match a single character that is a digit (0–9 in any Unicode script)”. While any regex tester can show you which of your samples the regex matches and doesn’t match, only RegexBuddy can accurately tell you what to expect. RegexBuddy’s regex tree enables white-box testing. Without it you might not have thought of testing a regex that contains \d on text with non-ASCII digits, only to get bug reports later when your software is exported around the world.

When the brief descriptions of the regex tree are not clear enough, just click the Explain Token button to access RegexBuddy’s detailed regular expression tutorial. It will open at the page that explains the item selected in the regex tree.

You can export the regex tree to an HTML file to document the regular expression outside of RegexBuddy. Moving the mouse over the tree highlights corresponding parts, as you can see below.

      
Only US$ 39.95
Windows XP, Vista, 7, 8, 8.1, 10, and 11
100% satisfied or money back

Example: Matching a Pair of HTML Bold Tags

<B[^>]*>(.*?)</B>

  • Match the characters "<B" literally
  • Match a single character not present in the list: one of the characters ">"
    • Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
  • Match the character ">" literally
  • Match the regular expression below and capture its match into backreference 1
    • Match any single character
      • Between zero and unlimited times, as few times as possible, expanding as needed (lazy)
  • Match the characters "</B>" literally

Confidently Work With Regular Expressions

Of course, the only way to be 100% sure if a regex matches a particular piece of text is to try it and find out. Just click on the Test tab, click the Highlight button, and type in the text or open the file you want to test the regex against. You will see right away what matches, and what does not.

Once you understand the pattern, store the regular expression into a RegexBuddy library for later reuse. Or, edit the regex and replace the original.

RegexBuddy takes the mystery out of regular expressions. Never again encounter a regex that you can’t comprehend. Get your own copy now!

Let RegexBuddy Make Regex Easy for You

“I have learned more about regular expressions from [RegexBuddy and its regex tutorial] than from anywhere else. Regex has moved from the realm of ‘arcane magic’ to a valued tool I truly enjoy and can wrap my head around.”
— Josiah Hudson
  14 October 2021, Michigan, USA
“Today I finally purchased your software to help fix a bug in some lexer regular expressions. Within 5 minutes of deciding to purchase the bug was fixed. The tree view of the regex made it so easy to find the problem.”
— Robert Stehwien
  29 November 2007, New Mexico, USA
“I bought RegexBuddy a few months ago, being a bit reluctant about creating those complex regex queries.

“I have to say that I am truly amazed by the program. I now solve complex tasks fairly quickly with it. It definitely delivers what it promises and makes regex as easy as it can be. I use it almost on a daily basis now and it makes my life as a PHP programmer much easier.”
— Joris Vincken
  24 September 2006, The Netherlands